using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace KarliCardsGui.Converters
{
    public class BooleanToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool bValue = (bool)value;
            if (parameter != null && parameter.ToString() == "Inverse")
            {
                bValue = !bValue;
            }
            return bValue ? Visibility.Visible : Visibility.Hidden;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Visibility visibility = (Visibility)value;
            bool isVisible = visibility == Visibility.Visible;
            if (parameter != null && parameter.ToString() == "Inverse")
            {
                isVisible = !isVisible;
            }
            return isVisible;
        }
    }
} 